package com.xiaocikuai.smallchunks.service.Card;


import com.xiaocikuai.smallchunks.entity.Card.CardChunks;
import com.xiaocikuai.smallchunks.mapper.Card.CardChunksMapper;
import com.xiaocikuai.smallchunks.mapper.Word.WordMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class CardChunksService {
    @Resource
    private CardChunksMapper cardChunksMapper;
    @Resource
    private WordMapper wordMapper;
    public boolean collectionAdd(long uid, int cid, LocalDateTime time){
        return cardChunksMapper.collectionAdd(cid, uid, time );
    }

    public boolean collectionDel(long uid, int cid){
        return cardChunksMapper.collectionDel(cid, uid);
    }

    public boolean chunkAdd(CardChunks card, String word){
        Integer wordId;
        if(wordMapper.selectId(word) == null){
            wordMapper.insertNew(word);
        }
        wordId = wordMapper.selectId(word);
        card.setWordId(wordId);
        return cardChunksMapper.insertCardChunk(card);
    }

//    public List<CardChunks> collectionCards(String token, int pid){
//
//    }


}
